home *** CD-ROM | disk | FTP | other *** search
- class classes.ww_interface.Fightbox extends MovieClip
- {
- var EXPLOSION_MC;
- var UNITS_MC;
- var SKIP_MODE;
- var SKIP;
- var GAME_CLASS;
- var LAST_FIGHT;
- var military1;
- var military2;
- var explosion1;
- var explosion2;
- var ter1;
- var ter2;
- var WINNER;
- var winTemp;
- var winNO;
- var ran1;
- var ran2;
- var onEnterFrame;
- var dieces_limit;
- var dieces_no;
- var rubbish;
- var ultraSkipA;
- var ultraSkipB;
- var ultraSkipP1;
- var ultraSkipP2;
- var docX;
- var i;
- function Fightbox()
- {
- super();
- this.EXPLOSION_MC = this._parent._parent.EXPLOSION_MC;
- this.UNITS_MC = this._parent._parent.UNITS_MC;
- var root = this;
- this.SKIP_MODE = false;
- this._visible = false;
- var _loc4_ = 1;
- while(_loc4_ <= 8)
- {
- this["d" + _loc4_]._visible = false;
- _loc4_ = _loc4_ + 1;
- }
- this.SKIP.onRelease = function()
- {
- _global.SOUNDS.playSound("Click- głośniejszy.wav");
- root.SKIP_MODE = true;
- root._visible = false;
- root.ultraSkip();
- };
- }
- function registerGame(g)
- {
- this.GAME_CLASS = g;
- }
- function fight(A, B)
- {
- if(!this.SKIP_MODE)
- {
- this.LAST_FIGHT = getTimer();
- this.resetDieces();
- this._visible = true;
- this.military1._visible = this.military2._visible = true;
- this.explosion1.gotoAndStop(1);
- this.explosion2.gotoAndStop(1);
- this.military1.un.text = A.unitsNO;
- this.military2.un.text = B.unitsNO;
- this.military1.army_ico.gotoAndStop(A.army);
- this.military1.army_ico.filters = [];
- this.military1.army_ico.units.gotoAndStop(A.unitsNO);
- this.military1.flag.gotoAndStop(A.player);
- this.military2.army_ico.gotoAndStop(B.army);
- this.military2.army_ico.filters = [];
- this.military2.army_ico.units.gotoAndStop(B.unitsNO);
- this.military2.flag.gotoAndStop(B.player);
- this.ter1.gotoAndStop(A.player);
- this.ter2.gotoAndStop(B.player);
- var _loc8_ = 0;
- var _loc7_ = 0;
- this.WINNER = undefined;
- var _loc5_ = 0;
- while(_loc5_ < A.unitsNO)
- {
- var _loc6_ = this.random2(5) + 1;
- _loc8_ += _loc6_;
- _loc5_ = _loc5_ + 1;
- }
- _loc5_ = 0;
- while(_loc5_ < B.unitsNO)
- {
- _loc6_ = this.random2(5) + 1;
- _loc7_ += _loc6_;
- _loc5_ = _loc5_ + 1;
- }
- if(_loc8_ > _loc7_)
- {
- this.winTemp = A;
- this.winNO = 1;
- }
- else
- {
- this.winTemp = B;
- this.winNO = 2;
- }
- this.setUltraSkip(_loc8_,_loc7_,A,B);
- this.ran1.setTo(_loc8_);
- this.ran2.setTo(_loc7_);
- _global.SOUNDS.playSound("kości.wav");
- this.onEnterFrame = mx.utils.Delegate.create(this,this.fightFinished);
- this.dieces_limit = A.unitsNO + B.unitsNO;
- this.dieces_no = 0;
- this.rubbish = new Array();
- this.throwDices(A.player,A.unitsNO,1);
- this.throwDices(B.player,B.unitsNO,2);
- }
- else
- {
- _loc8_ = 0;
- _loc7_ = 0;
- this.WINNER = undefined;
- _loc5_ = 0;
- while(_loc5_ < A.unitsNO)
- {
- _loc6_ = this.random2(5) + 1;
- _loc8_ += _loc6_;
- _loc5_ = _loc5_ + 1;
- }
- _loc5_ = 0;
- while(_loc5_ < B.unitsNO)
- {
- _loc6_ = this.random2(5) + 1;
- _loc7_ += _loc6_;
- _loc5_ = _loc5_ + 1;
- }
- if(_loc8_ > _loc7_)
- {
- var _loc9_ = this;
- this.EXPLOSION_MC._x = this.UNITS_MC._x + B.unitsMC._x;
- this.EXPLOSION_MC._y = this.UNITS_MC._y + B.unitsMC._y;
- this.EXPLOSION_MC.gotoAndPlay(2);
- this.winTemp = A;
- this.EXPLOSION_MC.onEnterFrame = mx.utils.Delegate.create(this,this.fightFinished2);
- }
- else
- {
- this.EXPLOSION_MC._x = this.UNITS_MC._x + A.unitsMC._x;
- this.EXPLOSION_MC._y = this.UNITS_MC._y + A.unitsMC._y;
- this.EXPLOSION_MC.gotoAndPlay(2);
- this.winTemp = B;
- this.EXPLOSION_MC.onEnterFrame = mx.utils.Delegate.create(this,this.fightFinished2);
- }
- }
- }
- function setUltraSkip(pow1, pow2, A, B)
- {
- this.ultraSkipA = A;
- this.ultraSkipB = B;
- this.ultraSkipP1 = pow1;
- this.ultraSkipP2 = pow2;
- }
- function ultraSkip()
- {
- delete this.onEnterFrame;
- if(this.ultraSkipP1 > this.ultraSkipP2)
- {
- var _loc2_ = this;
- this.EXPLOSION_MC._x = this.UNITS_MC._x + this.ultraSkipB.unitsMC._x;
- this.EXPLOSION_MC._y = this.UNITS_MC._y + this.ultraSkipB.unitsMC._y;
- this.EXPLOSION_MC.gotoAndPlay(2);
- this.winTemp = this.ultraSkipA;
- this.EXPLOSION_MC.onEnterFrame = mx.utils.Delegate.create(this,this.fightFinished2);
- }
- else
- {
- this.EXPLOSION_MC._x = this.UNITS_MC._x + this.ultraSkipA.unitsMC._x;
- this.EXPLOSION_MC._y = this.UNITS_MC._y + this.ultraSkipA.unitsMC._y;
- this.EXPLOSION_MC.gotoAndPlay(2);
- this.winTemp = this.ultraSkipB;
- this.EXPLOSION_MC.onEnterFrame = mx.utils.Delegate.create(this,this.fightFinished2);
- }
- }
- function initCountdowns()
- {
- this.ran1.countTo();
- this.ran2.countTo();
- }
- function fightFinished()
- {
- if(this.SKIP_MODE == false)
- {
- if(this.ran1.finished() && this.ran2.finished() && this.explosion1._currentframe == 1 && this.explosion2._currentframe == 1)
- {
- if(this.winNO == 1)
- {
- this.explosion2.gotoAndPlay(2);
- }
- else
- {
- this.explosion1.gotoAndPlay(2);
- }
- }
- if(this.explosion1._currentframe == 7)
- {
- this.military1._visible = false;
- }
- if(this.explosion2._currentframe == 7)
- {
- this.military2._visible = false;
- }
- if(this.explosion1._currentframe == this.explosion1._totalframes || this.explosion2._currentframe == this.explosion2._totalframes)
- {
- this.WINNER = this.winTemp;
- this.GAME_CLASS.fightFinished();
- this._visible = false;
- delete this.onEnterFrame;
- }
- }
- }
- function fightFinished2()
- {
- if(this.EXPLOSION_MC._currentframe == 7)
- {
- this.WINNER = this.winTemp;
- this.GAME_CLASS.fightFinished();
- }
- if(this.EXPLOSION_MC._currentframe == this.EXPLOSION_MC._totalframes)
- {
- delete this.EXPLOSION_MC.onEnterFrame;
- }
- }
- function random2(z)
- {
- return Math.round(Math.random() * z);
- }
- function throwDices(player, units, terr)
- {
- var root = this;
- var i = 0;
- while(i < units)
- {
- var _loc2_ = this["d" + player].duplicateMovieClip("dice" + player + "_" + i,terr * 10 + i);
- this.rubbish.push(_loc2_);
- _loc2_._x = this["gen" + terr]._x;
- _loc2_._xscale = _loc2_._yscale = 70;
- if(terr == 1)
- {
- _loc2_.docX = _loc2_._x + 15;
- }
- if(terr == 2)
- {
- _loc2_.docX = _loc2_._x - 15 - _loc2_._width;
- }
- _loc2_._y = this["gen" + terr]._y + i * 25;
- _loc2_.i = (i + 2) / 2;
- _loc2_.onEnterFrame = function()
- {
- this._x += (this.docX - this._x) / this.i;
- if(Math.abs(this._x - this.docX) < 1)
- {
- root.dieces_no = root.dieces_no + 1;
- if(root.dieces_no == root.dieces_limit)
- {
- root.initCountdowns();
- }
- this._x = this.docX;
- delete this.onEnterFrame;
- }
- };
- i++;
- }
- }
- function resetWinner()
- {
- this.WINNER = undefined;
- }
- function resetSkipMode()
- {
- this.SKIP._visible = true;
- this.SKIP_MODE = false;
- }
- function resetDieces()
- {
- var _loc2_ = 0;
- while(_loc2_ < this.rubbish.length)
- {
- this.rubbish[_loc2_].removeMovieClip();
- _loc2_ = _loc2_ + 1;
- }
- }
- function kill()
- {
- delete this.EXPLOSION_MC.onEnterFrame;
- }
- }
-